//
//  HWTabBarController.m
//  HWPromoteProjectAPP
//
//  Created by 陈道斌 on 2020/1/20.
//  Copyright © 2020 陈道斌. All rights reserved.
//

#import "HWTabBarController.h"
#import "HWHomePageViewController.h" //  首页
#import "HWPromoteViewController.h" // 推广
#import "HWManagementViewController.h" // 管理
#import "MyViewController.h" //  我的
#import "HWNavigationViewController.h"
#import "HWPromoteProjectAPP-Swift.h"
@interface HWTabBarController ()<UITabBarControllerDelegate>

@end

@implementation HWTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
     self.delegate = self;
    
      if ([[HWLocallyStoredData getAppStr] isEqualToString:@"3"]) {
          
          
          
          HWHomePageViewController *firstPage = [[HWHomePageViewController alloc] init];
          [self addControllerWithTitle:@"首页" imageName:@"home_Tabar" selectImage:@"home_Tabar" controller:firstPage];
          
          // 推广
 //          HWPromoteViewController *fenLei = [[HWPromoteViewController alloc] init];
  //          [self addControllerWithTitle:@"推广" imageName:@"tuiguan_tabar" selectImage:@"tuguan_sel_tabar" controller:fenLei];
          
          // 管理
          HWManagementViewController *Trading = [[HWManagementViewController alloc]init];
          [self addControllerWithTitle:@"管理" imageName:@"guanLi_tabar" selectImage:@"guanli_sele_tabar" controller:Trading];
          
          
          MyViewController *my = [[MyViewController alloc]init];
          [self addControllerWithTitle:@"我的" imageName:@"weixuanzhondemy_ico" selectImage:@"My_sele_tabar" controller:my];
          
          
          
          
         
      } else  {
          
          HWHomePageViewController *firstPage = [[HWHomePageViewController alloc] init];
          [self addControllerWithTitle:@"首页" imageName:@"tabbar_Home_Normal" selectImage:@"tabbar_Home_Select" controller:firstPage];
          
          // 推广
          HWPromoteViewController *fenLei = [[HWPromoteViewController alloc] init];
          [self addControllerWithTitle:@"推广" imageName:@"tuiguan_tabar" selectImage:@"tuguan_sel_tabar" controller:fenLei];
          
//          HWAssetsController *assetsController = [[HWAssetsController alloc] init];
//          [self addControllerWithTitle:@"资产" imageName:@"tabbar_Assets_Normal" selectImage:@"tabbar_Assets_Select" controller:assetsController];
          
          // 管理
          HWManagementViewController *Trading = [[HWManagementViewController alloc]init];
          [self addControllerWithTitle:@"管理" imageName:@"guanLi_tabar" selectImage:@"guanli_sele_tabar" controller:Trading];
          
          
          MyViewController *my = [[MyViewController alloc]init];
          [self addControllerWithTitle:@"我的" imageName:@"weixuanzhondemy_ico" selectImage:@"My_sele_tabar" controller:my];
          
     
     }
    

    
}

//禁止tab多次点击
-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
    UIViewController *tbselect=tabBarController.selectedViewController;
    if([tbselect isEqual:viewController]){
        return NO;
    }
    return YES;
}


- (void)addControllerWithTitle:(NSString *)title imageName:(NSString *)imageName selectImage:(NSString *)selectImage controller:(UIViewController *)controller {
    HWNavigationViewController *nav = [[HWNavigationViewController alloc] initWithRootViewController:controller];
    controller.tabBarItem.image = [UIImage imageNamed:imageName];
    controller.title = title;
   // self.tabBar.tintColor = UIColorFromRGB(0x139cea);
    self.tabBar.tintColor  = RGB(88, 121, 255);
    
    
    controller.tabBarItem.selectedImage = [[UIImage imageNamed:selectImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self addChildViewController:nav];
    
    
}



@end
